﻿Imports System.Net
Imports System.IO

Public Class SXMLCreator
    Sub AuthProxy()

    End Sub

    Function CreateXML()
        'move SoapServerUrl should be moved to confic file.
        Dim SoapServerUrl As String = "http://www.smsglobal.com/mobileworks/soapserver.php"
        Dim wRequest As HttpWebRequest = TryCast(WebRequest.Create(SoapServerUrl), HttpWebRequest)
        wRequest.Proxy.Credentials = New NetworkCredential("Veli5", "tzs2zf6p")

        wRequest.Method = "POST"
        wRequest.ContentType = "text/xml"
        ' request.UseDefaultCredentials = True
        wRequest.Headers.Add("SOAPAction", "urn:MobileWorks#apiValidateLogin")
        ' wRequest.Headers.Add("Content-Type", "text/xml")

        Dim XMLdoc As XDocument = XDocument.Load("shane.xml")

        Dim writer = New StreamWriter(wRequest.GetRequestStream())
        writer.WriteLine(XMLdoc.ToString())
        writer.Close()

        Using rsp = wRequest.GetResponse()
            wRequest.GetRequestStream().Close()
            If rsp IsNot Nothing Then
                Using answerReader = New StreamReader(rsp.GetResponseStream())
                    Dim readString = answerReader.ReadToEnd()
                    'do whatever you want with it\

                    MsgBox(readString.ToString())
                    Console.WriteLine(readString.ToString())
                    Console.ReadLine()
                End Using
            End If

        End Using



        Return Nothing
    End Function


End Class
